package com.wits.qso.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.wits.platform.entity.BaseEntity;

@Entity
@Table(name="qso_bookcase")
public class BookCase extends BaseEntity {
	private static final long serialVersionUID = -8885575827758682266L;

	/**书柜代码*/
	private String id;
	/**教师Id*/
	private Teacher terId;
	/**教材Id*/
	private MaterialD matId;
	
	@Id
	@GenericGenerator(name = "idGen", 
					strategy = "com.wits.platform.common.id.generator.IDGenerator",
					parameters={ 
								@Parameter(name = "segment_value", value = "QSO_BOOKCASE_ID"),
								@Parameter(name="table_name",value="wits_id_generator"),
								@Parameter(name="value_column_name",value="gen_value"),
								@Parameter(name="segment_column_name",value="gen_name"),
								@Parameter(name="segment_value_length",value="10"),
								@Parameter(name="sq_format",value="%08d"),
								@Parameter(name="sq_prefix",value="BC")
					})
	@GeneratedValue(generator = "idGen")
	@Column(name = "bookcase_id", nullable = false, insertable = true, updatable = false, length = 10)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="bookcase_terid")
	public Teacher getTerId() {
		return terId;
	}


	public void setTerId(Teacher terId) {
		this.terId = terId;
	}
	
	@ManyToOne
	@JoinColumn(name="bookcase_matid")
	public MaterialD getMatId() {
		return matId;
	}

	public void setMatId(MaterialD matId) {
		this.matId = matId;
	}

	@Override
	public String display() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString(){
		return "{\"id\":\"" + this.id 
				+ "\",\"teaTitle\":\"" + this.terId.getTerName()
				+ "\",\"name\":\"" + this.matId.getTitle() 
				+ "\",\"intro\":\"" + this.matId.getIntro()
				+ "\" }";
	}
}
